<?php


namespace app\hotel\controller;


use app\hotel\validate\FilesValidate;
use app\BaseController;
use app\Code;
use app\lib\exception\ServiceException;
use app\service\AuthService;
use app\service\FilesService;
use think\App;
use think\exception\ValidateException;

class FilesController extends BaseController
{
    private $service;

    public function __construct(App $app)
    {
        $this->service = new FilesService();
        parent::__construct($app);
    }

    public function upload(){
        $files = $this->request->file('files');

        $paths = [];
        foreach ($files as $file){
            validate(FilesValidate::class)
                ->scene('file')
                ->check(['image' => $file]);

            $paths[] = $this->service->uploadFile($file);
        }
        
        return $this->returnJson($paths);
    }

}